# Require X11
FIND_PACKAGE(X11 REQUIRED)

# Require Xinerama
FIND_PACKAGE(Xinerama REQUIRED)

# Require Xrandr
FIND_PACKAGE(Xrandr REQUIRED)

# Check for NVCtrlLib
FIND_PACKAGE(NVCtrlLib)

# Sources
SET(XCEED_SRC
    ${CMAKE_SOURCE_DIR}/src/xcd_log.c
    ${CMAKE_SOURCE_DIR}/src/xcd_util.c
    ${CMAKE_SOURCE_DIR}/src/xcd_x11.c
    ${CMAKE_SOURCE_DIR}/src/xceed.c)

ADD_EXECUTABLE(${EXE_NAME} ${XCEED_SRC})
SET_SOURCE_FILES_PROPERTIES(${XCEED_SRC} PROPERTIES
                            COMPILE_FLAGS "-O0 -g -Wall -Werror")

INCLUDE_DIRECTORIES(${X11_INCLUDE_DIR}
                    ${Xinerama_INCLUDE_DIR}
                    ${Xrandr_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(${EXE_NAME}
                      ${X11_LIBRARIES}
                      ${Xinerama_LIBRARIES}
                      ${Xrandr_LIBRARIES})

IF(NVCtrlLib_FOUND)
    INCLUDE_DIRECTORIES(${NVCtrlLib_INCLUDE_DIR})
    TARGET_LINK_LIBRARIES(${EXE_NAME} ${NVCtrlLib_LIBRARIES})
ENDIF(NVCtrlLib_FOUND)

